try {
	var tagName = "%@".toLowerCase();
	var text = "%@".toLowerCase();
	var errStr = "no element with text '" + text + "' found in page";

	if ("a" == tagName) {
		var target = getLinkOrButtonWithTagNameAndText("a", text);
		if (target && target.href) {
			document.location = target.href;
		} else {
			throw new Error(errStr);
		}
	} else {
		target = getLinkOrButtonWithTagNameAndText("button", text);
		if (!target) {
			target = getInputWithText(text);
		}
		if (target) {
			target.click();
		} else {
			throw new Error(errStr);
		}
	}

	function getLinkOrButtonWithTagNameAndText(tagName, text) {
		var els = document.getElementsByTagName(tagName);
		var el;
		for (var i = 0; i < els.length; i++) {
			el = els[i];
			if (el.innerText && el.innerText.toLowerCase() == text) {
				return el;
			}
		}
		return null;
	}

	function getInputWithText(text) {
		var els = document.getElementsByTagName("input");
		var el;
		var type;
		var value;
		for (var i = 0; i < els.length; i++) {
			el = els[i];
			type = el.getAttribute("type");
			type = (type) ? type.toLowerCase() : "";
			value = el.getAttribute("value");
			value = (value) ? value.toLowerCase() : "";
			if ((type == "submit" || type == "button") && value == text) {
				return el;
			}
		}
		return null;
	}
} catch (e) {
	return "_TOD_ERROR: " + e.toString();
}
